<?php
	//接收数据
	header("Content-Type:text/html;charset=utf-8");
	$province=$_POST['sheng'];
	//连接数据库
	$con=mysql_connect('localhost','root','dx123');
	//选择数据库
	mysql_select_db("novel");
	//编写sql语句查询当前所选省的id
	$sql="select code from province where name="."'".$province."'";
	//执行sql语句
	$resourse=mysql_query($sql,$con);
	$row=mysql_fetch_row($resourse);
	//编写sql语句查询当前所选省的所有市
	$sqlcitys="select name from city where provincecode='".$row[0]."'";
	//执行sql语句
	$result="[";
	$resoursecitys=mysql_query($sqlcitys,$con);
	while($rowcity=mysql_fetch_row($resoursecitys))
	{
		//使用json数据格式返回
		$result.="{'name':'".$rowcity[0]."'},";
	}
	$result=substr($result,0,-1);
	$result.="]";
	//file_put_contents("I:/test.txt",$result."\r\n",FILE_APPEND);
	echo $result;
?>